* (bug 8737) Fix warnings caused by incorrect use of `/dev/null` when piping
process error output under Windows
* (bug 7890) Don't list redirects to special pages in Special:BrokenRedirects
-* (bug 10783) Resizing PNG-24 images causes all alpha channel transparency to be
- lost and transparent pixels to be turned black
+* (bug 10783) Resizing PNG-24 images with GD no longer causes all alpha
+ channel transparency to be lost and transparent pixels to be turned black
* (bug 9339) General error pages were transforming messages and their parameters
in the wrong order
* (bug 9026) Incorrect heading numbering when viewing Special:Statistics with
* Fixed invalid XHTML in Special:Upload
* (bug 11013) Make sure dl() is available before attempting to use it to check
available databases in installer
+* Resizing transparent GIF images with GD now retains transparency by skipping
+ resampling
+
== API changes since 1.10 ==
wfDebug( "$err\n" );
return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
}
- list( $loader, /* $colorStyle */, $saveType ) = $typemap[$mimeType];
+ list( $loader, $colorStyle, $saveType ) = $typemap[$mimeType];
if( !function_exists( $loader ) ) {
$err = "Incomplete GD library configuration: missing function $loader";
$src_image = call_user_func( $loader, $srcPath );
$dst_image = imagecreatetruecolor( $physicalWidth, $physicalHeight );
- //PNG-24 Alpha Trans
- $background = imagecolorallocate($dst_image, 0, 0, 0); //Make $dst_image all black
- ImageColorTransparent($dst_image, $background); //Make $dst_image transparent
- imagealphablending($dst_image, false);
-
- imagecopyresampled( $dst_image, $src_image,
- 0,0,0,0,
- $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
+ // Initialise the destination image to transparent instead of
+ // the default solid black, to support PNG and GIF transparency nicely
+ $background = imagecolorallocate( $dst_image, 0, 0, 0 );
+ imagecolortransparent( $dst_image, $background );
+ imagealphablending( $dst_image, false );
+
+ if( $colorStyle == 'palette' ) {
+ // Don't resample for paletted GIF images.
+ // It may just uglify them, and completely breaks transparency.
+ imagecopyresized( $dst_image, $src_image,
+ 0,0,0,0,
+ $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
+ } else {
+ imagecopyresampled( $dst_image, $src_image,
+ 0,0,0,0,
+ $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
+ }
- imagesavealpha($dst_image, true);
+ imagesavealpha( $dst_image, true );
call_user_func( $saveType, $dst_image, $dstPath );
imagedestroy( $dst_image );